package servlettest;

import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

/**
 * Created by Administrator on 2017/9/25.
 */
public class GServlet extends GenericServlet {
    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        PrintWriter out = servletResponse.getWriter();
        ServletConfig servletConfig = this.getServletConfig();
        Enumeration e = servletConfig.getInitParameterNames();
        while (e.hasMoreElements()){
            String name = (String) e.nextElement();
            String value = servletConfig.getInitParameter(name);
            out.write(name+"  =  "+value+"\n");
        }
        String value = (String) servletConfig.getServletContext().getAttribute("param");
        out.write(value+"\n");
        String path = servletConfig.getServletContext().getRealPath("/");
        out.write(path);
    }
}
